import React, { Component } from 'react'
import FromContainer from './FromContainer'

export default class From extends Component {
  constructor(){
    super();
    this.state={
      name : ""
    }
  }
  render() {
    return (
      <FromContainer>
        <div>
          <input type="text" value={this.state.name}
          onChange={(event)=>{
            this.setState({
              name:event.target.value
            })
          }}
          className="txt" placeholder="请输入信息"/>
          <button onClick={()=>this.props.search(this.state.name)}>查询</button>
          <button onClick={()=>{
            this.props.add(this.state.name)
            this.setState({
              name : ''
            })
          }}>添加</button>
        </div>
      </FromContainer>
    )
  }
}
